package com.dmwork.service.message.controller.front.me;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dmwork.common.base.result.R;
import com.dmwork.common.base.util.JwtInfo;
import com.dmwork.common.base.util.JwtUtils;
import com.dmwork.service.message.entity.CommentLikeMessage;
import com.dmwork.service.message.entity.CommentMessage;
import com.dmwork.service.message.service.CommentLikeMessageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/front/dm_work/message/comment_like_message/me")
public class FrontMeCommentLikeMessageController {

    @Autowired
    private CommentLikeMessageService commentLikeMessageService;

    @ApiOperation("获取未读的点赞消息数")
    @GetMapping("get_unread_comment_like_message_count")
    public R getUnreadCommentMessageCount(HttpServletRequest request) {
        JwtInfo jwtInfo = JwtUtils.getCustomerInfoByJwtToken(request);
        QueryWrapper<CommentLikeMessage> queryWrapper = new QueryWrapper<CommentLikeMessage>()
                .eq("customer_id", jwtInfo.getId())
                .eq("read_status", 0);
        int count = commentLikeMessageService.count(queryWrapper);
        return R.ok().data("count", count);
    }

}
